package edu.udlap.spring2008.is300.finalexam.app.mvc.view;

import edu.udlap.spring2008.is300.finalexam.app.mvc.controller.AppController;
import edu.udlap.spring2008.is300.finalexam.framework.mvc.controller.Controller;
import edu.udlap.spring2008.is300.finalexam.framework.mvc.model.Model;
import edu.udlap.spring2008.is300.finalexam.framework.mvc.view.ViewComponent;
import edu.udlap.spring2008.is300.finalexam.framework.mvc.view.ViewFactory;
import java.awt.BorderLayout;
import java.awt.Dimension;
//import javax.swing.BoxLayout;
import javax.swing.ImageIcon;

/**
 *
 * @author Ruslán Ledesma Garza
 */
public class AppViewFactory implements ViewFactory
{

    @Override
    public ViewComponent newStandardView(String title, Model model)
    {
        ///controller creation...
        Controller controller = new AppController(model);
        
        ///component creation...
        
        ///main window and mainPanel...
        ViewWindow window =
                new ViewWindow(title,
                                 controller,
                                 new Dimension(900,500));
        ViewPanel mainPanel =
                new ViewPanel(new BorderLayout());
        
        ///toolbar...
        ViewToolbarControls toolbar = new ViewToolbarControls();
        
        ///side panel...
        ViewTabbedPanel sidePanel =
                new ViewTabbedPanel();
        
        ViewPropertiesControls propertiesControls =
                new ViewPropertiesControls();
        ViewFavoritesControls favoritesControls =
                new ViewFavoritesControls();
        ViewImageFilterControls imageFilterControls =
                new ViewImageFilterControls();
        
        ImageIcon tabPropertiesIcon = new ImageIcon("imgs/tabproperties.png");
        ImageIcon tabFavoritesIcon = new ImageIcon("imgs/tabfavorites.png");
        ImageIcon tabFilterIcon = new ImageIcon("imgs/tabfilter.png");
        
        ///central panel...
        ViewModeSwitchPanel modeSwitchPanel =
                new ViewModeSwitchPanel(true);
        ViewImageGridControls viewImageGridControls =
                new ViewImageGridControls();
        ViewImageSlideShowControls viewImageSlideShowControls =
                new ViewImageSlideShowControls();
        
        
        
        ///composite tree construction...
        sidePanel.addChild(propertiesControls, tabPropertiesIcon,
                "Properties", "Edits the properties of the currently selected" +
                " image.");
        sidePanel.addChild(favoritesControls, tabFavoritesIcon,
                "Favorites", "Edits the properties of the currently selected" +
                " image.");
        sidePanel.addChild(imageFilterControls, tabFilterIcon,
                "Filter Images", "Edits the filter applied to the image " +
                "library.");
        
        modeSwitchPanel.addGridModeChild(viewImageGridControls);
        modeSwitchPanel.addSlideShowModeChild(viewImageSlideShowControls);
        
        mainPanel.addChild(modeSwitchPanel, BorderLayout.CENTER);
        mainPanel.addChild(toolbar, BorderLayout.NORTH);
        mainPanel.addChild(sidePanel, BorderLayout.WEST);
        
        window.addChild(mainPanel);
        
        ///initialize view...
        controller.setInitialState();
       
        ///return...
        return window;
    }

    /*
    @Override
    public ViewComponent newStandardView(String title, Model model)
    {
        ///controller creation...
        Controller controller = new AppController(model);
        
        ///component creation...
        
        ///main window and mainPanel...
        ViewWindow window =
                new ViewWindow(title,
                                 controller,
                                 new Dimension(700,500));
        ViewPanel mainPanel =
                new ViewPanel(new BorderLayout());
        
        ///toolbar...
        ViewToolbarControls toolbar = new ViewToolbarControls();
        
        ///side panel...
        ViewPanel sidePanel =
                new ViewPanel();
        ViewTitledPanel propertiesPanel =
                new ViewTitledPanel("Properties");
        ViewTitledPanel favoritesPanel =
                new ViewTitledPanel("Favorites");
        ViewTitledPanel imageFilterPanel =
                new ViewTitledPanel("Image Filter");
        
        ViewPropertiesControls propertiesControls =
                new ViewPropertiesControls();
        ViewFavoritesControls favoritesControls =
                new ViewFavoritesControls();
        ViewImageFilterControls imageFilterControls =
                new ViewImageFilterControls();
        
        ///central panel...
        ViewImageGridControls viewImageGridControls =
                new ViewImageGridControls();
        
        ///set layouts...
        BoxLayout boxLayout =
                new BoxLayout((Container) sidePanel.getComponent(), BoxLayout.Y_AXIS);
        sidePanel.setLayout(boxLayout);
        
        ///composite tree construction...
        propertiesPanel.addChild(propertiesControls);
        
        favoritesPanel.addChild(favoritesControls);
        
        imageFilterPanel.addChild(imageFilterControls);
        
        sidePanel.addChild(propertiesPanel);
        sidePanel.addChild(favoritesPanel);
        sidePanel.addChild(imageFilterPanel);
        
        mainPanel.addChild(toolbar, BorderLayout.NORTH);
        mainPanel.addChild(sidePanel, BorderLayout.WEST);
        mainPanel.addChild(viewImageGridControls, BorderLayout.CENTER);
        
        window.addChild(mainPanel);
        
        ///initialize view...
        controller.setInitialState();
       
        ///return...
        return window;
    }
    */    
}
